package kassiopeia.commons.model.xml;

import java.io.InputStream;
import kassiopeia.commons.model.Coordinates;
import kassiopeia.commons.model.plugin.Output;
import kassiopeia.commons.model.plugin.Parameter;
import kassiopeia.commons.model.plugin.PluginDescriptor;

import com.thoughtworks.xstream.XStream;

public final class PluginDescriptorXmlSerializer {

    private static XStream xstream = new XStream();

    private PluginDescriptorXmlSerializer() {}

    static {
        xstream.processAnnotations(new Class[]{Output.class,
                Parameter.class,PluginDescriptor.class,Coordinates.class});
    }

    public static PluginDescriptor fromXml(String xml) {
        return (PluginDescriptor)xstream.fromXML(xml);
    }

    public static PluginDescriptor fromXml(InputStream stream) {
        return (PluginDescriptor)xstream.fromXML(stream);
    }

    public static String toXml(PluginDescriptor pluginDescriptor) {
        return xstream.toXML(pluginDescriptor);
    }
}
